package com.heisen.systemapi.service.fallback;

import com.heisen.base.entity.Api;
import com.heisen.base.exception.RRException;
import com.heisen.systemapi.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author sen
 * @description
 * @date 2023/12/18 17:32
 */
@Slf4j
@Component
public class UserServiceFallback implements FallbackFactory<UserService> {

    @Override
    public UserService create(Throwable throwable) {
        return new UserService() {
            @Override
            public String hello(String name) {
                log.error("调用User服务出错", throwable);
                return "调用User服务出错";
            }

            @Override
            public Api LoginByName(String username) {
                log.info("调用User [‘LoginByName’] 服务出错  e:",throwable);
                throw new RRException("调用User [‘LoginByName’] 服务出错 " );
               // return Api.fail("调用User [‘LoginByName’] 服务出错");
            }

        };
    }
}
